package org.wejob.web.connect;

import org.wejob.command.CodeDispatcherIpml;
import org.wejob.command.DecodeDispatcherIpml;
import org.wejob.web.WebClient;

public class ConnectManager {
    CodeDispatcherIpml codeDispatcher;
    DecodeDispatcherIpml decodeDispatcher;


    public ConnectManager(){
        this.decodeDispatcher=new DecodeDispatcherIpml(4);
        this.codeDispatcher=new CodeDispatcherIpml(4);
    }
    ConnectManager(CodeDispatcherIpml dispatcherIpml, DecodeDispatcherIpml decodeDispatcher){
        this.codeDispatcher=dispatcherIpml;
        this.decodeDispatcher=decodeDispatcher;
    }
    public void startConnect(WebClient webClient){
        //读写事件发送给读写处理线程
        this.decodeDispatcher.dispatch(webClient);
        this.codeDispatcher.dispatch(webClient);
        //启动selector线程
        new Thread(webClient).start();
    }
}
